﻿/*
 * FeatureCollection
 * 
 * initial implementation : 5.12.2008
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
using System.Collections;
using System.Collections.Generic;
using Petra.Gis.DataServices.Metadata;


namespace Petra.Gis.DataServices
{

  /// <summary>
  /// for non System.Data based data source this class represents dataset, 
  /// where geometry data can be retreived from any IEnumerable collection.
  /// Optionally <c>IGeometryConverter</c> can be specified. This is
  /// useful when <c>FeatureCollection</c> contains multiple (geometry) fields
  /// or geometry is not directly available in enumerator.
  /// </summary>
  public abstract class FeatureSetBase : IFeatureSet
  {

    /// <summary>
    /// xaml constr.
    /// </summary>
    protected FeatureSetBase()
    {
      this.Parameters = new FeatureSetParameters();
    }



    /// <summary>
    /// this method does nothing for FeatureCollection as feature collection is not data source based.
    /// </summary>
    /// <param name="forceMetadataByFeatureName">not supported, does nothing</param>
    public void ForceFeatureMetadata(string forceMetadataByFeatureName){ }




    protected abstract IEnumerable data { get; set; }



    /// <summary>
    /// get/set data for feature set
    /// </summary>
    public IEnumerable Data 
    {
      get { return data;}
      set { data = value; }
    }




    protected abstract IGeometryConverter geometryConverter { get; set; }



    /// <summary>
    /// get/set geometry converter for feature set.
    /// </summary>
    public IGeometryConverter GeometryConverter
    {
      get { return geometryConverter; }
      set { geometryConverter = value; }
    }




    private FeatureMetadata _metadata;

    /// <summary>
    /// set/get FeatureMetadata for this set of features
    /// </summary>
    public virtual FeatureMetadata Metadata
    {
      get { return _metadata; }

      protected set
      {
        if(value == null)
          throw new ArgumentException("invalid null metadata");

        _metadata = value;
      }
    }




    /// <summary>
    /// gets feature parameter dictionary
    /// </summary>
    public IFeatureSetParameters Parameters
    { get; protected set; }





    /// <summary>
    /// FeatureSet is in memory, object based always and only
    /// </summary>
    public FeatureDataSourceTypeEnum FeatureDataSourceType
    {
      get
      {
        return FeatureDataSourceTypeEnum.ObjectDataSource;
      }
    }


  }
}
